home *** CD-ROM | disk | FTP | other *** search
/ Power Programmierung 2 / Power-Programmierung CD 2 (Tewi)(1994).iso / gnu / djgpp / src / gas-211 / gas / config / obj-coff.h < prev    next >
Encoding:
C/C++ Source or Header  |  1993-06-26  |  23.5 KB  |  656 lines

  1. /* coff object file format
  2.    Copyright (C) 1989, 1990, 1991, 1992 Free Software Foundation, Inc.
  3.  
  4.    This file is part of GAS.
  5.  
  6.    GAS is free software; you can redistribute it and/or modify
  7.    it under the terms of the GNU General Public License as published by
  8.    the Free Software Foundation; either version 2, or (at your option)
  9.    any later version.
  10.  
  11.    GAS is distributed in the hope that it will be useful,
  12.    but WITHOUT ANY WARRANTY; without even the implied warranty of
  13.    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  14.    GNU General Public License for more details.
  15.  
  16.    You should have received a copy of the GNU General Public License
  17.    along with GAS; see the file COPYING.  If not, write to
  18.    the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.  */
  19.  
  20. #define OBJ_COFF 1
  21.  
  22. #include "targ-cpu.h"
  23.  
  24. #if defined (BFD_HEADERS) || defined (BFD_ASSEMBLER)
  25.  
  26. /* This internal_lineno crap is to stop namespace pollution from the
  27.    bfd internal coff headerfile. */
  28.  
  29. #include "bfd.h"
  30. #define internal_lineno bfd_internal_lineno
  31. #include "coff/internal.h"
  32. #undef internal_lineno
  33.  
  34. #ifdef BFD_ASSEMBLER
  35. #include "../bfd/libcoff.h"
  36. #endif
  37.  
  38. #ifdef TC_A29K
  39. #include "coff/a29k.h"
  40.  
  41. /*
  42.   #undef RELOC
  43.   #undef SYMENT
  44.   #undef AUXENT
  45.   #undef LINENO
  46.   #undef FILHDR
  47.   #undef SCNHDR
  48.   #define RELOC struct internal_reloc
  49.   #define SYMENT struct internal_syment
  50.   #define AUXENT union internal_auxent
  51.   #define SCNHDR struct internal_scnhdr
  52.   #define LINENO struct bfd_internal_lineno
  53.   #define AOUTHDR struct internal_aouthdr
  54.   #define FILHDR struct internal_filehdr
  55.   #define AOUTHDRSZ sizeof(struct external_aouthdr)
  56.   */
  57. /*#define x_endndx x_endndx.l
  58.   #define x_tagndx x_tagndx.l*/
  59. #define TARGET_FORMAT "coff-a29k-big"
  60. extern bfd *stdoutput;
  61.  
  62. #endif /* TC_A29K */
  63.  
  64. #ifdef TC_I960
  65. #include "coff/i960.h"
  66. #define TARGET_FORMAT "coff-i960-big"
  67. #endif
  68.  
  69. #ifdef TC_I386
  70. #  include "coff/i386.h"
  71. #  define TARGET_FORMAT "coff-i386"
  72. extern bfd *stdoutput;
  73.  
  74. #endif /* TC_I386 */
  75.  
  76. #ifdef TC_M68K
  77. #  include "coff/m68k.h"
  78. #  define TARGET_FORMAT "coff-m68k"
  79. #endif /* TC_M68K */
  80.  
  81. #else /* not BFD_HEADERS */
  82.  
  83. #ifdef USE_NATIVE_HEADERS
  84. #include <filehdr.h>
  85. #include <aouthdr.h>
  86. #include <scnhdr.h>
  87. #include <storclass.h>
  88. #include <linenum.h>
  89. #include <syms.h>
  90. #include <reloc.h>
  91. #include <sys/types.h>
  92. #else /* not USE_NATIVE_HEADERS */
  93. #include "coff_gnu.h"
  94. #endif /* not USE_NATIVE_HEADERS */
  95.  
  96. #endif /* not BFD_HEADERS */
  97.  
  98. #ifndef BFD_ASSEMBLER
  99. /* Define some processor dependent values according to the processor
  100.    we are on. */
  101. #ifdef TC_M68K
  102.  
  103. #define BYTE_ORDERING        F_AR32W    /* See filehdr.h for more info. */
  104. #ifndef FILE_HEADER_MAGIC
  105. #define FILE_HEADER_MAGIC    MC68MAGIC    /* ... */
  106. #endif /* FILE_HEADER_MAGIC */
  107.  
  108. #endif /* TC_M68K */
  109.  
  110. #if defined(TC_I386)
  111.  
  112. #define BYTE_ORDERING        F_AR32WR    /* See filehdr.h for more info. */
  113. #ifndef FILE_HEADER_MAGIC
  114. #define FILE_HEADER_MAGIC    I386MAGIC    /* ... */
  115. #endif /* FILE_HEADER_MAGIC */
  116.  
  117. #endif /* TC_I386 */
  118.  
  119. #if defined(TC_I960)
  120.  
  121. #define BYTE_ORDERING        F_AR32WR    /* See filehdr.h for more info. */
  122. #ifndef FILE_HEADER_MAGIC
  123. #define FILE_HEADER_MAGIC    I960ROMAGIC    /* ... */
  124. #endif /* FILE_HEADER_MAGIC */
  125.  
  126. #endif /* TC_I960 */
  127.  
  128. #if defined(TC_A29K)
  129.  
  130. #define BYTE_ORDERING        F_AR32W    /* big endian. */
  131. #ifndef FILE_HEADER_MAGIC
  132. #define FILE_HEADER_MAGIC    SIPFBOMAGIC
  133. #endif /* FILE_HEADER_MAGIC */
  134.  
  135. #endif /* TC_A29K */
  136.  
  137. #ifndef OBJ_COFF_MAX_AUXENTRIES
  138. #define OBJ_COFF_MAX_AUXENTRIES 1
  139. #endif /* OBJ_COFF_MAX_AUXENTRIES */
  140.  
  141. extern const short seg_N_TYPE[];
  142. extern const segT N_TYPE_seg[];
  143.  
  144. /* Magic number of paged executable. */
  145. #define DEFAULT_MAGIC_NUMBER_FOR_OBJECT_FILE    (FILE_HEADER_MAGIC)
  146.  
  147. #ifndef BFD_HEADERS
  148.  
  149. /* Add these definitions to have a consistent convention for all the
  150.    types used in COFF format. */
  151. #define AOUTHDR            struct aouthdr
  152. #define AOUTHDRSZ        sizeof(AOUTHDR)
  153. #endif
  154.  
  155. #endif /* not BFD_ASSEMBLER */
  156.  
  157.  
  158. /* SYMBOL TABLE */
  159.  
  160. /* targets may also set this */
  161. #ifndef SYMBOLS_NEED_BACKPOINTERS
  162. #define SYMBOLS_NEED_BACKPOINTERS 1
  163. #endif /* SYMBOLS_NEED_BACKPOINTERS */
  164.  
  165. #ifdef BFD_ASSEMBLER
  166.  
  167. #ifdef TC_I960
  168. #define I960_SYM_FIELDS        struct symbol *bal;
  169. #else
  170. #define I960_SYM_FIELDS
  171. #endif
  172.  
  173. #define TARGET_SYMBOL_FIELDS    unsigned long sy_flags; I960_SYM_FIELDS
  174.  
  175. #ifndef OBJ_COFF_MAX_AUXENTRIES
  176. #define OBJ_COFF_MAX_AUXENTRIES 1
  177. #endif
  178.  
  179. #else
  180.  
  181. /* Symbol table entry data type */
  182.  
  183. typedef struct
  184.   {
  185. #ifdef BFD_HEADERS
  186.     struct internal_syment ost_entry;    /* Basic symbol */
  187.     union internal_auxent ost_auxent[OBJ_COFF_MAX_AUXENTRIES];    /* Auxiliary entry. */
  188. #else
  189.     SYMENT ost_entry;        /* Basic symbol */
  190.     AUXENT ost_auxent[OBJ_COFF_MAX_AUXENTRIES];    /* Auxiliary entry. */
  191. #endif
  192.     unsigned int ost_flags;    /* obj_coff internal use only flags */
  193.   }
  194. obj_symbol_type;
  195. #endif /* ! BFD_ASSEMBLER */
  196.  
  197. #ifdef BFD_ASSEMBLER
  198. #define SYM_AUXENT(S)    (&coffsymbol ((S)->bsym)->native[1].u.auxent)
  199. #else
  200. #define SYM_AUXENT(S)    (&(S)->sy_symbol.ost_auxent[0])
  201. #endif
  202.  
  203. #define DO_NOT_STRIP    0
  204. #define DO_STRIP    1
  205.  
  206. #ifndef BFD_ASSEMBLER
  207.  
  208. /* Symbol table macros and constants */
  209.  
  210. /* Possible and usefull section number in symbol table
  211.  * The values of TEXT, DATA and BSS may not be portable.
  212.  */
  213.  
  214. #define C_TEXT_SECTION        ((short)1)
  215. #define C_DATA_SECTION        ((short)2)
  216. #define C_BSS_SECTION        ((short)3)
  217. #define C_ABS_SECTION        N_ABS
  218. #define C_UNDEF_SECTION        N_UNDEF
  219. #define C_DEBUG_SECTION        N_DEBUG
  220. #define C_NTV_SECTION        N_TV
  221. #define C_PTV_SECTION        P_TV
  222. #define C_REGISTER_SECTION    4
  223.  
  224. /*
  225.  *  Macros to extract information from a symbol table entry.
  226.  *  This syntaxic indirection allows independence regarding a.out or coff.
  227.  *  The argument (s) of all these macros is a pointer to a symbol table entry.
  228.  */
  229.  
  230. /* Predicates */
  231. /* True if the symbol is external */
  232. #define S_IS_EXTERNAL(s)        ((s)->sy_symbol.ost_entry.n_scnum == C_UNDEF_SECTION)
  233. /* True if symbol has been defined, ie :
  234.    section > 0 (DATA, TEXT or BSS)
  235.    section == 0 and value > 0 (external bss symbol) */
  236. #define S_IS_DEFINED(s)         ((s)->sy_symbol.ost_entry.n_scnum > C_UNDEF_SECTION || \
  237.                  ((s)->sy_symbol.ost_entry.n_scnum == C_UNDEF_SECTION && \
  238.                   (s)->sy_symbol.ost_entry.n_value > 0))
  239. /* True if a debug special symbol entry */
  240. #define S_IS_DEBUG(s)        ((s)->sy_symbol.ost_entry.n_scnum == C_DEBUG_SECTION)
  241. /* True if a symbol is local symbol name */
  242. /* A symbol name whose name begin with ^A is a gas internal pseudo symbol */
  243. #define S_IS_LOCAL(s)        (S_GET_NAME(s)[0] == '\001' || \
  244.                  (s)->sy_symbol.ost_entry.n_scnum == C_REGISTER_SECTION || \
  245.                  (S_LOCAL_NAME(s) && !flagseen['L']))
  246. /* True if a symbol is not defined in this file */
  247. #define S_IS_EXTERN(s)        ((s)->sy_symbol.ost_entry.n_scnum == 0 && (s)->sy_symbol.ost_entry.n_value == 0)
  248. /*
  249.  * True if a symbol can be multiply defined (bss symbols have this def
  250.  * though it is bad practice)
  251.  */
  252. #define S_IS_COMMON(s)        ((s)->sy_symbol.ost_entry.n_scnum == 0 && (s)->sy_symbol.ost_entry.n_value != 0)
  253. /* True if a symbol name is in the string table, i.e. its length is > 8. */
  254. #define S_IS_STRING(s)        (strlen(S_GET_NAME(s)) > 8 ? 1 : 0)
  255.  
  256. /* Accessors */
  257. /* The name of the symbol */
  258. #define S_GET_NAME(s)        ((char*)(s)->sy_symbol.ost_entry.n_offset)
  259. /* The pointer to the string table */
  260. #define S_GET_OFFSET(s)         ((s)->sy_symbol.ost_entry.n_offset)
  261. /* The zeroes if symbol name is longer than 8 chars */
  262. #define S_GET_ZEROES(s)        ((s)->sy_symbol.ost_entry.n_zeroes)
  263. /* The value of the symbol */
  264. #define S_GET_VALUE(s)        ((unsigned) ((s)->sy_symbol.ost_entry.n_value))
  265. /* The numeric value of the segment */
  266. #define S_GET_SEGMENT(s)        (N_TYPE_seg[(s)->sy_symbol.ost_entry.n_scnum+4])
  267. /* The data type */
  268. #define S_GET_DATA_TYPE(s)    ((s)->sy_symbol.ost_entry.n_type)
  269. /* The storage class */
  270. #define S_GET_STORAGE_CLASS(s)    ((s)->sy_symbol.ost_entry.n_sclass)
  271. /* The number of auxiliary entries */
  272. #define S_GET_NUMBER_AUXILIARY(s)    ((s)->sy_symbol.ost_entry.n_numaux)
  273.  
  274. /* Modifiers */
  275. /* Set the name of the symbol */
  276. #define S_SET_NAME(s,v)        ((s)->sy_symbol.ost_entry.n_offset = (unsigned long)(v))
  277. /* Set the offset of the symbol */
  278. #define S_SET_OFFSET(s,v)    ((s)->sy_symbol.ost_entry.n_offset = (v))
  279. /* The zeroes if symbol name is longer than 8 chars */
  280. #define S_SET_ZEROES(s,v)        ((s)->sy_symbol.ost_entry.n_zeroes = (v))
  281. /* Set the value of the symbol */
  282. #define S_SET_VALUE(s,v)    ((s)->sy_symbol.ost_entry.n_value = (v))
  283. /* The numeric value of the segment */
  284. #define S_SET_SEGMENT(s,v)    ((s)->sy_symbol.ost_entry.n_scnum = SEGMENT_TO_SYMBOL_TYPE(v))
  285. /* The data type */
  286. #define S_SET_DATA_TYPE(s,v)    ((s)->sy_symbol.ost_entry.n_type = (v))
  287. /* The storage class */
  288. #define S_SET_STORAGE_CLASS(s,v)    ((s)->sy_symbol.ost_entry.n_sclass = (v))
  289. /* The number of auxiliary entries */
  290. #define S_SET_NUMBER_AUXILIARY(s,v)    ((s)->sy_symbol.ost_entry.n_numaux = (v))
  291.  
  292. /* Additional modifiers */
  293. /* The symbol is external (does not mean undefined) */
  294. #define S_SET_EXTERNAL(s)       { S_SET_STORAGE_CLASS(s, C_EXT) ; SF_CLEAR_LOCAL(s); }
  295.  
  296. #else /* BFD_ASSEMBLER */
  297.  
  298. /* The data type */
  299. #define S_GET_DATA_TYPE(s)    (coffsymbol ((s)->bsym)->native->u.syment.n_type)
  300. /* The storage class */
  301. #define S_GET_STORAGE_CLASS(s)    (coffsymbol((s)->bsym)->native->u.syment.n_sclass)
  302. /* The number of auxiliary entries */
  303. #define S_GET_NUMBER_AUXILIARY(s)    (coffsymbol((s)->bsym)->native->u.syment.n_numaux)
  304. /* The data type */
  305. #define S_SET_DATA_TYPE(s,v)    (S_GET_DATA_TYPE (s) = (v))
  306. /* The storage class */
  307. #define S_SET_STORAGE_CLASS(s,v)    (S_GET_STORAGE_CLASS (s) = (v))
  308. /* The number of auxiliary entries */
  309. #define S_SET_NUMBER_AUXILIARY(s,v)    (S_GET_NUMBER_AUXILIARY (s) = (v))
  310.  
  311. /* True if a symbol name is in the string table, i.e. its length is > 8. */
  312. #define S_IS_STRING(s)        (strlen(S_GET_NAME(s)) > 8 ? 1 : 0)
  313.  
  314.  
  315. #endif /* ! BFD_ASSEMBLER */
  316.  
  317. /* Auxiliary entry macros. SA_ stands for symbol auxiliary */
  318. /* Omit the tv related fields */
  319. /* Accessors */
  320.  
  321. #ifdef BFD_HEADERS
  322. #define SA_GET_SYM_TAGNDX(s)    (SYM_AUXENT (s)->x_sym.x_tagndx.l)
  323. #else
  324. #define SA_GET_SYM_TAGNDX(s)    (SYM_AUXENT (s)->x_sym.x_tagndx)
  325. #endif
  326. #define SA_GET_SYM_LNNO(s)    (SYM_AUXENT (s)->x_sym.x_misc.x_lnsz.x_lnno)
  327. #define SA_GET_SYM_SIZE(s)    (SYM_AUXENT (s)->x_sym.x_misc.x_lnsz.x_size)
  328. #define SA_GET_SYM_FSIZE(s)    (SYM_AUXENT (s)->x_sym.x_misc.x_fsize)
  329. #define SA_GET_SYM_LNNOPTR(s)    (SYM_AUXENT (s)->x_sym.x_fcnary.x_fcn.x_lnnoptr)
  330. #ifdef BFD_HEADERS
  331. #define SA_GET_SYM_ENDNDX(s)    (SYM_AUXENT (s)->x_sym.x_fcnary.x_fcn.x_endndx.l)
  332. #else
  333. #define SA_GET_SYM_ENDNDX(s)    (SYM_AUXENT (s)->x_sym.x_fcnary.x_fcn.x_endndx)
  334. #endif
  335. #define SA_GET_SYM_DIMEN(s,i)    (SYM_AUXENT (s)->x_sym.x_fcnary.x_ary.x_dimen[(i)])
  336. #define SA_GET_FILE_FNAME(s)    (SYM_AUXENT (s)->x_file.x_fname)
  337. #define SA_GET_SCN_SCNLEN(s)    (SYM_AUXENT (s)->x_scn.x_scnlen)
  338. #define SA_GET_SCN_NRELOC(s)    (SYM_AUXENT (s)->x_scn.x_nreloc)
  339. #define SA_GET_SCN_NLINNO(s)    (SYM_AUXENT (s)->x_scn.x_nlinno)
  340.  
  341. /* Modifiers */
  342. #ifndef BFD_ASSEMBLER
  343. #ifdef BFD_HEADERS
  344. #define SA_SET_SYM_TAGNDX(s,v)    (SYM_AUXENT (s)->x_sym.x_tagndx.l=(v))
  345. #define SA_SET_SYM_ENDNDX(s,v)    (SYM_AUXENT (s)->x_sym.x_fcnary.x_fcn.x_endndx.l=(v))
  346. #else
  347. #define SA_SET_SYM_ENDNDX(s,v)    (SYM_AUXENT (s)->x_sym.x_fcnary.x_fcn.x_endndx=(v))
  348. #define SA_SET_SYM_TAGNDX(s,v)    (SYM_AUXENT (s)->x_sym.x_tagndx=(v))
  349. #endif
  350. #endif
  351.  
  352. #define SA_SET_SYM_LNNO(s,v)    (SYM_AUXENT (s)->x_sym.x_misc.x_lnsz.x_lnno=(v))
  353. #define SA_SET_SYM_SIZE(s,v)    (SYM_AUXENT (s)->x_sym.x_misc.x_lnsz.x_size=(v))
  354. #define SA_SET_SYM_FSIZE(s,v)    (SYM_AUXENT (s)->x_sym.x_misc.x_fsize=(v))
  355. #define SA_SET_SYM_LNNOPTR(s,v)    (SYM_AUXENT (s)->x_sym.x_fcnary.x_fcn.x_lnnoptr=(v))
  356. #define SA_SET_SYM_DIMEN(s,i,v)    (SYM_AUXENT (s)->x_sym.x_fcnary.x_ary.x_dimen[(i)]=(v))
  357. #define SA_SET_FILE_FNAME(s,v)    strncpy(SYM_AUXENT (s)->x_file.x_fname,(v),FILNMLEN)
  358. #define SA_SET_SCN_SCNLEN(s,v)    (SYM_AUXENT (s)->x_scn.x_scnlen=(v))
  359. #define SA_SET_SCN_NRELOC(s,v)    (SYM_AUXENT (s)->x_scn.x_nreloc=(v))
  360. #define SA_SET_SCN_NLINNO(s,v)    (SYM_AUXENT (s)->x_scn.x_nlinno=(v))
  361.  
  362. /*
  363.  * Internal use only definitions. SF_ stands for symbol flags.
  364.  *
  365.  * These values can be assigned to sy_symbol.ost_flags field of a symbolS.
  366.  *
  367.  * You'll break i960 if you shift the SYSPROC bits anywhere else.  for
  368.  * more on the balname/callname hack, see tc-i960.h.  b.out is done
  369.  * differently.
  370.  */
  371.  
  372. #define SF_I960_MASK    (0x000001ff)    /* Bits 0-8 are used by the i960 port. */
  373. #define SF_SYSPROC    (0x0000003f)    /* bits 0-5 are used to store the sysproc number */
  374. #define SF_IS_SYSPROC    (0x00000040)    /* bit 6 marks symbols that are sysprocs */
  375. #define SF_BALNAME    (0x00000080)    /* bit 7 marks BALNAME symbols */
  376. #define SF_CALLNAME    (0x00000100)    /* bit 8 marks CALLNAME symbols */
  377.  
  378. #define SF_NORMAL_MASK    (0x0000ffff)    /* bits 12-15 are general purpose. */
  379.  
  380. #define SF_STATICS    (0x00001000)    /* Mark the .text & all symbols */
  381. #define SF_DEFINED    (0x00002000)    /* Symbol is defined in this file */
  382. #define SF_STRING    (0x00004000)    /* Symbol name length > 8 */
  383. #define SF_LOCAL    (0x00008000)    /* Symbol must not be emitted */
  384.  
  385. #define SF_DEBUG_MASK    (0xffff0000)    /* bits 16-31 are debug info */
  386.  
  387. #define SF_FUNCTION    (0x00010000)    /* The symbol is a function */
  388. #define SF_PROCESS    (0x00020000)    /* Process symbol before write */
  389. #define SF_TAGGED    (0x00040000)    /* Is associated with a tag */
  390. #define SF_TAG        (0x00080000)    /* Is a tag */
  391. #define SF_DEBUG    (0x00100000)    /* Is in debug or abs section */
  392. #define SF_GET_SEGMENT    (0x00200000)    /* Get the section of the forward symbol. */
  393. /* All other bits are unused. */
  394.  
  395. /* Accessors */
  396. #ifdef BFD_ASSEMBLER
  397. #define SF_GET(s)        ((s)->sy_flags)
  398. #define SF_GET_DEBUG(s)        ((s)->bsym->flags & BSF_DEBUGGING)
  399. #define SF_SET_DEBUG(s)        ((s)->bsym->flags |= BSF_DEBUGGING)
  400. #else
  401. #define SF_GET(s)        ((s)->sy_symbol.ost_flags)
  402. #define SF_GET_DEBUG(s)        ((s)->sy_symbol.ost_flags & SF_DEBUG)
  403. #define SF_SET_DEBUG(s)        ((s)->sy_symbol.ost_flags |= SF_DEBUG)
  404. #endif
  405. #define SF_GET_NORMAL_FIELD(s)    (SF_GET (s) & SF_NORMAL_MASK)
  406. #define SF_GET_DEBUG_FIELD(s)    (SF_GET (s) & SF_DEBUG_MASK)
  407. #define SF_GET_FILE(s)        (SF_GET (s) & SF_FILE)
  408. #define SF_GET_STATICS(s)    (SF_GET (s) & SF_STATICS)
  409. #define SF_GET_DEFINED(s)    (SF_GET (s) & SF_DEFINED)
  410. #define SF_GET_STRING(s)    (SF_GET (s) & SF_STRING)
  411. #define SF_GET_LOCAL(s)        (SF_GET (s) & SF_LOCAL)
  412. #define SF_GET_FUNCTION(s)      (SF_GET (s) & SF_FUNCTION)
  413. #define SF_GET_PROCESS(s)    (SF_GET (s) & SF_PROCESS)
  414. #define SF_GET_TAGGED(s)    (SF_GET (s) & SF_TAGGED)
  415. #define SF_GET_TAG(s)        (SF_GET (s) & SF_TAG)
  416. #define SF_GET_GET_SEGMENT(s)    (SF_GET (s) & SF_GET_SEGMENT)
  417. #define SF_GET_I960(s)        (SF_GET (s) & SF_I960_MASK)    /* used by i960 */
  418. #define SF_GET_BALNAME(s)    (SF_GET (s) & SF_BALNAME)    /* used by i960 */
  419. #define SF_GET_CALLNAME(s)    (SF_GET (s) & SF_CALLNAME)    /* used by i960 */
  420. #define SF_GET_IS_SYSPROC(s)    (SF_GET (s) & SF_IS_SYSPROC)    /* used by i960 */
  421. #define SF_GET_SYSPROC(s)    (SF_GET (s) & SF_SYSPROC)    /* used by i960 */
  422.  
  423. /* Modifiers */
  424. #define SF_SET(s,v)        (SF_GET (s) = (v))
  425. #define SF_SET_NORMAL_FIELD(s,v)(SF_GET (s) |= ((v) & SF_NORMAL_MASK))
  426. #define SF_SET_DEBUG_FIELD(s,v)    (SF_GET (s) |= ((v) & SF_DEBUG_MASK))
  427. #define SF_SET_FILE(s)        (SF_GET (s) |= SF_FILE)
  428. #define SF_SET_STATICS(s)    (SF_GET (s) |= SF_STATICS)
  429. #define SF_SET_DEFINED(s)    (SF_GET (s) |= SF_DEFINED)
  430. #define SF_SET_STRING(s)    (SF_GET (s) |= SF_STRING)
  431. #define SF_SET_LOCAL(s)        (SF_GET (s) |= SF_LOCAL)
  432. #define SF_CLEAR_LOCAL(s)    (SF_GET (s) &= ~SF_LOCAL)
  433. #define SF_SET_FUNCTION(s)      (SF_GET (s) |= SF_FUNCTION)
  434. #define SF_SET_PROCESS(s)    (SF_GET (s) |= SF_PROCESS)
  435. #define SF_SET_TAGGED(s)    (SF_GET (s) |= SF_TAGGED)
  436. #define SF_SET_TAG(s)        (SF_GET (s) |= SF_TAG)
  437. #define SF_SET_GET_SEGMENT(s)    (SF_GET (s) |= SF_GET_SEGMENT)
  438. #define SF_SET_I960(s,v)    (SF_GET (s) |= ((v) & SF_I960_MASK))    /* used by i960 */
  439. #define SF_SET_BALNAME(s)    (SF_GET (s) |= SF_BALNAME)    /* used by i960 */
  440. #define SF_SET_CALLNAME(s)    (SF_GET (s) |= SF_CALLNAME)    /* used by i960 */
  441. #define SF_SET_IS_SYSPROC(s)    (SF_GET (s) |= SF_IS_SYSPROC)    /* used by i960 */
  442. #define SF_SET_SYSPROC(s,v)    (SF_GET (s) |= ((v) & SF_SYSPROC))    /* used by i960 */
  443.  
  444. /* File header macro and type definition */
  445.  
  446. #ifndef BFD_ASSEMBLER
  447. /*
  448.  * File position calculators. Beware to use them when all the
  449.  * appropriate fields are set in the header.
  450.  */
  451.  
  452. #ifdef OBJ_COFF_OMIT_OPTIONAL_HEADER
  453. #define OBJ_COFF_AOUTHDRSZ (0)
  454. #else
  455. #define OBJ_COFF_AOUTHDRSZ (AOUTHDRSZ)
  456. #endif /* OBJ_COFF_OMIT_OPTIONAL_HEADER */
  457.  
  458. #define H_GET_FILE_SIZE(h) \
  459.     (long)(FILHSZ + OBJ_COFF_AOUTHDRSZ + \
  460.        H_GET_NUMBER_OF_SECTIONS(h) * SCNHSZ + \
  461.        H_GET_TEXT_SIZE(h) + H_GET_DATA_SIZE(h) + \
  462.        H_GET_RELOCATION_SIZE(h) + H_GET_LINENO_SIZE(h) + \
  463.        H_GET_SYMBOL_TABLE_SIZE(h) + \
  464.        (h)->string_table_size)
  465. #define H_GET_TEXT_FILE_OFFSET(h) \
  466.     (long)(FILHSZ + OBJ_COFF_AOUTHDRSZ + \
  467.        H_GET_NUMBER_OF_SECTIONS(h) * SCNHSZ)
  468. #define H_GET_DATA_FILE_OFFSET(h) \
  469.     (long)(FILHSZ + OBJ_COFF_AOUTHDRSZ + \
  470.        H_GET_NUMBER_OF_SECTIONS(h) * SCNHSZ + \
  471.        H_GET_TEXT_SIZE(h))
  472. #define H_GET_BSS_FILE_OFFSET(h) 0
  473. #define H_GET_RELOCATION_FILE_OFFSET(h) \
  474.     (long)(FILHSZ + OBJ_COFF_AOUTHDRSZ + \
  475.        H_GET_NUMBER_OF_SECTIONS(h) * SCNHSZ + \
  476.        H_GET_TEXT_SIZE(h) + H_GET_DATA_SIZE(h))
  477. #define H_GET_LINENO_FILE_OFFSET(h) \
  478.     (long)(FILHSZ + OBJ_COFF_AOUTHDRSZ + \
  479.        H_GET_NUMBER_OF_SECTIONS(h) * SCNHSZ + \
  480.        H_GET_TEXT_SIZE(h) + H_GET_DATA_SIZE(h) + \
  481.        H_GET_RELOCATION_SIZE(h))
  482. #define H_GET_SYMBOL_TABLE_FILE_OFFSET(h) \
  483.     (long)(FILHSZ + OBJ_COFF_AOUTHDRSZ + \
  484.        H_GET_NUMBER_OF_SECTIONS(h) * SCNHSZ + \
  485.        H_GET_TEXT_SIZE(h) + H_GET_DATA_SIZE(h) + \
  486.        H_GET_RELOCATION_SIZE(h) + H_GET_LINENO_SIZE(h))
  487.  
  488. /* Accessors */
  489. /* aouthdr */
  490. #define H_GET_MAGIC_NUMBER(h)           ((h)->aouthdr.magic)
  491. #define H_GET_VERSION_STAMP(h)        ((h)->aouthdr.vstamp)
  492. #define H_GET_TEXT_SIZE(h)              ((h)->aouthdr.tsize)
  493. #define H_GET_DATA_SIZE(h)              ((h)->aouthdr.dsize)
  494. #define H_GET_BSS_SIZE(h)               ((h)->aouthdr.bsize)
  495. #define H_GET_ENTRY_POINT(h)            ((h)->aouthdr.entry)
  496. #define H_GET_TEXT_START(h)        ((h)->aouthdr.text_start)
  497. #define H_GET_DATA_START(h)        ((h)->aouthdr.data_start)
  498. /* filehdr */
  499. #define H_GET_FILE_MAGIC_NUMBER(h)    ((h)->filehdr.f_magic)
  500. #define H_GET_NUMBER_OF_SECTIONS(h)    ((h)->filehdr.f_nscns)
  501. #define H_GET_TIME_STAMP(h)        ((h)->filehdr.f_timdat)
  502. #define H_GET_SYMBOL_TABLE_POINTER(h)    ((h)->filehdr.f_symptr)
  503. #define H_GET_SYMBOL_COUNT(h)        ((h)->filehdr.f_nsyms)
  504. #define H_GET_SYMBOL_TABLE_SIZE(h)    (H_GET_SYMBOL_COUNT(h) * SYMESZ)
  505. #define H_GET_SIZEOF_OPTIONAL_HEADER(h)    ((h)->filehdr.f_opthdr)
  506. #define H_GET_FLAGS(h)            ((h)->filehdr.f_flags)
  507. /* Extra fields to achieve bsd a.out compatibility and for convenience */
  508. #define H_GET_RELOCATION_SIZE(h)       ((h)->relocation_size)
  509. #define H_GET_STRING_SIZE(h)            ((h)->string_table_size)
  510. #define H_GET_LINENO_SIZE(h)            ((h)->lineno_size)
  511.  
  512. #ifndef OBJ_COFF_OMIT_OPTIONAL_HEADER
  513. #define H_GET_HEADER_SIZE(h)        (sizeof(FILHDR) \
  514.                      + sizeof(AOUTHDR)\
  515.                      + (H_GET_NUMBER_OF_SECTIONS(h) * SCNHSZ))
  516. #else /* OBJ_COFF_OMIT_OPTIONAL_HEADER */
  517. #define H_GET_HEADER_SIZE(h)        (sizeof(FILHDR) \
  518.                      + (H_GET_NUMBER_OF_SECTIONS(h) * SCNHSZ))
  519. #endif /* OBJ_COFF_OMIT_OPTIONAL_HEADER */
  520.  
  521. #define H_GET_TEXT_RELOCATION_SIZE(h)    (text_section_header.s_nreloc * RELSZ)
  522. #define H_GET_DATA_RELOCATION_SIZE(h)    (data_section_header.s_nreloc * RELSZ)
  523.  
  524. /* Modifiers */
  525. /* aouthdr */
  526. #define H_SET_MAGIC_NUMBER(h,v)         ((h)->aouthdr.magic = (v))
  527. #define H_SET_VERSION_STAMP(h,v)    ((h)->aouthdr.vstamp = (v))
  528. #define H_SET_TEXT_SIZE(h,v)            ((h)->aouthdr.tsize = (v))
  529. #define H_SET_DATA_SIZE(h,v)            ((h)->aouthdr.dsize = (v))
  530. #define H_SET_BSS_SIZE(h,v)             ((h)->aouthdr.bsize = (v))
  531. #define H_SET_ENTRY_POINT(h,v)          ((h)->aouthdr.entry = (v))
  532. #define H_SET_TEXT_START(h,v)        ((h)->aouthdr.text_start = (v))
  533. #define H_SET_DATA_START(h,v)        ((h)->aouthdr.data_start = (v))
  534. /* filehdr */
  535. #define H_SET_FILE_MAGIC_NUMBER(h,v)    ((h)->filehdr.f_magic = (v))
  536. #define H_SET_NUMBER_OF_SECTIONS(h,v)    ((h)->filehdr.f_nscns = (v))
  537. #define H_SET_TIME_STAMP(h,v)        ((h)->filehdr.f_timdat = (v))
  538. #define H_SET_SYMBOL_TABLE_POINTER(h,v)    ((h)->filehdr.f_symptr = (v))
  539. #define H_SET_SYMBOL_TABLE_SIZE(h,v)    ((h)->filehdr.f_nsyms = (v))
  540. #define H_SET_SIZEOF_OPTIONAL_HEADER(h,v) ((h)->filehdr.f_opthdr = (v))
  541. #define H_SET_FLAGS(h,v)        ((h)->filehdr.f_flags = (v))
  542. /* Extra fields to achieve bsd a.out compatibility and for convinience */
  543. #define H_SET_RELOCATION_SIZE(h,t,d)     ((h)->relocation_size = (t)+(d))
  544. #define H_SET_STRING_SIZE(h,v)          ((h)->string_table_size = (v))
  545. #define H_SET_LINENO_SIZE(h,v)          ((h)->lineno_size = (v))
  546.  
  547. /* Segment flipping */
  548.  
  549. typedef struct
  550.   {
  551. #ifdef BFD_HEADERS
  552.     struct internal_aouthdr aouthdr;    /* a.out header */
  553.     struct internal_filehdr filehdr;    /* File header, not machine dep. */
  554. #else
  555.     AOUTHDR aouthdr;        /* a.out header */
  556.     FILHDR filehdr;        /* File header, not machine dep. */
  557. #endif
  558.     long string_table_size;    /* names + '\0' + sizeof(int) */
  559.     long relocation_size;    /* Cumulated size of relocation
  560.                        information for all sections in
  561.                        bytes. */
  562.     long lineno_size;        /* Size of the line number information
  563.                        table in bytes */
  564.   }
  565.  
  566. object_headers;
  567. #endif /* ! BFD_ASSEMBLER */
  568.  
  569. /* --------------  Line number handling ------- */
  570. extern int text_lineno_number;
  571.  
  572. #ifndef BFD_ASSEMBLER
  573. /* line numbering stuff. */
  574.  
  575. typedef struct internal_lineno
  576.   {
  577. #ifdef BFD_HEADERS
  578.     struct bfd_internal_lineno line;
  579. #else
  580.     LINENO line;        /* The lineno structure itself */
  581. #endif
  582.     char *frag;            /* Frag to which the line number is related */
  583.     struct internal_lineno *next;    /* Forward chain pointer */
  584.   } lineno;
  585.  
  586. extern lineno *lineno_lastP;
  587. extern lineno *lineno_rootP;
  588. #define OBJ_EMIT_LINENO(a, b, c)    obj_emit_lineno((a),(b),(c))
  589.  
  590. #endif /* not BFD_ASSEMBLER */
  591.  
  592. void obj_emit_lineno PARAMS ((char **where, lineno * line, char *file_start));
  593.  
  594. /* stack stuff */
  595. typedef struct
  596.   {
  597.     unsigned long chunk_size;
  598.     unsigned long element_size;
  599.     unsigned long size;
  600.     char *data;
  601.     unsigned long pointer;
  602.   }
  603.  
  604. stack;
  605.  
  606. char *stack_pop PARAMS ((stack * st));
  607. char *stack_push PARAMS ((stack * st, char *element));
  608. char *stack_top PARAMS ((stack * st));
  609. stack *stack_init PARAMS ((unsigned long chunk_size,
  610.                unsigned long element_size));
  611. void c_dot_file_symbol PARAMS ((char *filename));
  612. void obj_extra_stuff PARAMS ((object_headers * headers));
  613. void stack_delete PARAMS ((stack * st));
  614.  
  615. #ifndef tc_headers_hook
  616. void tc_headers_hook PARAMS ((object_headers * headers));
  617. #endif
  618.  
  619. #ifndef tc_coff_symbol_emit_hook
  620. void tc_coff_symbol_emit_hook PARAMS ((/* symbolS * */));
  621. #endif
  622.  
  623. #define obj_check_file_symbols coff_check_file_symbols
  624.  
  625. #ifndef BFD_ASEMBLER
  626. void c_section_header PARAMS ((
  627. #ifdef BFD_HEADERS
  628.                    struct internal_scnhdr *header,
  629. #else
  630.                    SCNHDR * header,
  631. #endif
  632.                    char *name, long core_address, long size,
  633.                    long data_ptr, long reloc_ptr, long lineno_ptr,
  634.                    long reloc_number, long lineno_number,
  635.                    long alignment));
  636. #endif
  637.  
  638. /* sanity check */
  639.  
  640. #ifdef TC_I960
  641. #ifndef C_LEAFSTAT
  642. hey ! Where is the C_LEAFSTAT definition ? i960 - coff support is depending on it.
  643. #endif /* no C_LEAFSTAT */
  644. #endif /* TC_I960 */
  645. #ifndef BFD_ASSEMBLER
  646. #ifdef BFD_HEADERS
  647. extern struct internal_scnhdr data_section_header;
  648. extern struct internal_scnhdr text_section_header;
  649. #else
  650. extern SCNHDR data_section_header;
  651. extern SCNHDR text_section_header;
  652. #endif
  653. #endif
  654.  
  655. /* end of obj-coff.h */
  656.